import { create } from 'zustand';
import { persist } from 'zustand/middleware';

export interface AdminStore {
  isAdmin: boolean;
  setIsAdmin: (boolean: boolean) => void;
  adminContentKey: string;
  setAdminContentKey: (key: string) => void;
}

export const useAdminState = create<AdminStore>()(
  persist(
    (set) => ({
      isAdmin: false,
      adminContentKey: 'home',
      setIsAdmin: (boolean) => set({ isAdmin: boolean }),
      setAdminContentKey: (index) => set({ adminContentKey: index }),
    }),
    {
      name: 'admin-storage',
    },
  ),
);
